﻿using System;
using System.Web.Security;

namespace ECommerce.Administration.Controls
{
	public partial class EditRole : AdminBaseUsercontrol
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			if(!IsPostBack)
			{
				LabelAddRoleTitle.Text = GetLocalResourceString("Admin.EditRole.Add.Title");

				ButtonSave.Text = GetLocalResourceString("Admin.SaveButtonText");
			}
		}

		protected void ButtonSave_Click(object sender, EventArgs e)
		{
			var theRoleName = TextRoleName.Text.Trim();

			if(!string.IsNullOrEmpty(theRoleName))
			{
				if(!Roles.RoleExists(theRoleName))
				{
					Roles.CreateRole(theRoleName);
				}
			}
		}
	}
}